<?php

namespace app\common\behavior;


use think\facade\Config;
use think\facade\Env;

class InitHook {
    public function run(&$request) {
        //未安装时不执行
        if (substr(request()->pathinfo(), 0, 7) != 'install' && is_file(Env::get('config_path') . 'database.php')) {
            //初始化某些配置信息
            if (cache('db_config_data')) {
                \think\Config::set(cache('db_config_data'));
            } else {
                $config = model('common/Config');
                \think\Config::set($config->lists());
            }

            //扩展插件
            \think\Loader::addNamespace('addons', Env::get('root_path') . '/addons/');

            $this->setHook();

            //设置模型内容路由
            $this->setRoute();
        }
    }


}